package com.zzr.demo.redis.controller;

import com.zzr.demo.redis.service.RecommendationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: xiaomi
 * @date: 2021/10/9
 * @description: 输入样例：
 * Redis使用手册；
 * "Java并发编程之美:79.0",
 * "Linux内核设计的艺术:42.0",
 * "Redis设计与实现:38.0",
 * "MySql技术内幕:31.0",
 * "Kafka入门与实践:15.0",
 * "MySql计数内幕:14.0",
 * "深入理解Nginx:1.0"
 */
@RestController
@RequestMapping("recommendation/commodity")
@Api(tags = "推荐：商品同类推荐")
@Slf4j
public class CommodityRecommendationController {

    @Autowired
    RecommendationService recommendationService;

    @GetMapping("/addPath/{source}/{target}")
    @ApiOperation("新增行为")
    public boolean addPath(@PathVariable("source") String source, @PathVariable("target") String target) {
        boolean b = recommendationService.addPath(source, target);
        return b;
    }

    @GetMapping("/recommendTop10/{source}")
    @ApiOperation("同类推荐")
    public List<String> recommendTop10(@PathVariable("source") String source) {
        List<String> strings = recommendationService.recommendationTop10(source);
        return strings;
    }
}
